﻿<UserControl x:Class="theeg.DependencyAnalysis.CommonAddin.Views.DependencyList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:dataModel="clr-namespace:DependencyAnalysis.DataModel;assembly=DependencyAnalysis"
             xmlns:views="clr-namespace:theeg.DependencyAnalysis.CommonAddin.Views"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="600">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/CommonStyles.xaml"></ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>

            <DataTemplate x:Key="DependencyDescriptorTemplate" DataType="dataModel:DependencyDescriptor">
                <Grid x:Name="content">
                    <StackPanel Orientation="Horizontal">
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                            <Button Style="{StaticResource SelectButtonStyle}" DataContext="{Binding Source.ImplementingType.Submodule.Module}">
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="../Resources/Module.png"></Image>
                                    <TextBlock Text="{Binding Name}"></TextBlock>
                                </StackPanel>
                            </Button>
                            <Button Style="{StaticResource SelectButtonStyle}" DataContext="{Binding Source.ImplementingType.Submodule}">
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="../Resources/Namespace.png"></Image>
                                    <TextBlock Text="{Binding Name}"></TextBlock>
                                </StackPanel>
                            </Button>
                            <Button Style="{StaticResource SelectButtonStyle}" DataContext="{Binding Source.ImplementingType}">
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="../Resources/Class.png"></Image>
                                    <TextBlock Text="{Binding Name}"></TextBlock>
                                </StackPanel>
                            </Button>
                            <Button Style="{StaticResource SelectButtonStyle}" DataContext="{Binding Source}">
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="../Resources/Method.png"></Image>
                                    <TextBlock Text="{Binding Name}"></TextBlock>
                                </StackPanel>
                            </Button>
                        </StackPanel>
                        <Viewbox Height="16" Margin="2,0">
                            <Path Fill="Gold" Stroke="White" StrokeThickness="3">
                                <Path.Data>M21,14 L68,14 54,0 62,0 79,17 62,34 54,34 68,20 21,20z</Path.Data>
                            </Path>
                        </Viewbox>
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                            <Button Style="{StaticResource SelectButtonStyle}" DataContext="{Binding Target.ImplementingType.Submodule.Module}">
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="../Resources/Module.png"></Image>
                                    <TextBlock Text="{Binding Name}"></TextBlock>
                                </StackPanel>
                            </Button>
                            <Button Style="{StaticResource SelectButtonStyle}" DataContext="{Binding Target.ImplementingType.Submodule}">
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="../Resources/Namespace.png"></Image>
                                    <TextBlock Text="{Binding Name}"></TextBlock>
                                </StackPanel>
                            </Button>
                            <Button Style="{StaticResource SelectButtonStyle}" DataContext="{Binding Target.ImplementingType}">
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="../Resources/Class.png"></Image>
                                    <TextBlock Text="{Binding Name}"></TextBlock>
                                </StackPanel>
                            </Button>
                            <Button Style="{StaticResource SelectButtonStyle}" DataContext="{Binding Target}">
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="../Resources/Method.png"></Image>
                                    <TextBlock Text="{Binding Name}"></TextBlock>
                                </StackPanel>
                            </Button>
                        </StackPanel>
                    </StackPanel>
                </Grid>
                <DataTemplate.Triggers>
                    <Trigger Property="ListBox.AlternationIndex" Value="0">
                        <Setter Property="Background" Value="Transparent" 
                            TargetName="content"></Setter>
                    </Trigger>
                    <Trigger Property="ListBox.AlternationIndex" Value="1">
                        <Setter Property="Background" Value="#22FFFFFF" 
                            TargetName="content"></Setter>
                    </Trigger>
                </DataTemplate.Triggers>
            </DataTemplate>

        </ResourceDictionary>
    </UserControl.Resources>
    <Border CornerRadius="5" Background="#FF222222" BorderBrush="Black" BorderThickness="1">
        <Border CornerRadius="5" Background="#FF222222" BorderBrush="White" BorderThickness="2">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>
                <Border VerticalAlignment="Bottom" BorderBrush="#FF25334B" BorderThickness="2"></Border>
                <TextBlock Text="Dependencies" FontWeight="Bold" FontSize="18" Foreground="White" HorizontalAlignment="Left"></TextBlock>
                <Button Command="{Binding CloseListCommand}" Style="{StaticResource FlatButtonStyle}" HorizontalAlignment="Right">
                    <Viewbox Width="25">
                        <Canvas Width="100" Height="100">
                            <Path Stroke="#FFFFFFFF" StrokeThickness="6" Fill="#01000000">
                                <Path.Data>
                                    <EllipseGeometry RadiusX="47" RadiusY="47" Center="50,50" />
                                </Path.Data>
                            </Path>
                            <Path Stroke="#FFFFFFFF" StrokeThickness="6">
                                <Path.Data>M27,27L73,73 M27,73 L73,27</Path.Data>
                            </Path>
                        </Canvas>
                    </Viewbox>
                </Button>
                <ItemsControl ItemsSource="{Binding Dependencies}" ItemTemplate="{StaticResource DependencyDescriptorTemplate}"
                      Background="Transparent" AlternationCount="2" Grid.Row="1">
                    <ItemsControl.Template>
                        <ControlTemplate>
                            <ScrollViewer x:Name="DependenciesScrollViewer" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto" PanningMode="Both">
                                <views:LateRenderStackPanel IsItemsHost="True" GoverningScrollViewer="{Binding ElementName=DependenciesScrollViewer}"></views:LateRenderStackPanel>
                            </ScrollViewer>
                        </ControlTemplate>
                    </ItemsControl.Template>
                </ItemsControl>
            </Grid>
        </Border>
    </Border>
</UserControl>
